# Huawei Technologies Co.,Ltd.

set(LEXICALENV_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lexicalenv.txt)
set(LEXICALENV_BIN ${CMAKE_CURRENT_BINARY_DIR}/lexicalenv.abc)
set(LEXICALENV_PA ${CMAKE_CURRENT_BINARY_DIR}/lexicalenv.pa)
set(LEXICALENV_JS ${CMAKE_CURRENT_SOURCE_DIR}/lexicalenv.js)
set(LEXICALENV_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${LEXICALENV_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${LEXICALENV_OUTPUT}
    COMMENT "running javascript lexicalenv testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${LEXICALENV_JS} --dump-assembly --output ${LEXICALENV_BIN} > ${LEXICALENV_PA}
    COMMAND rm -f ${LEXICALENV_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${LEXICALENV_OUTPUT}
    COMMAND bash ${LEXICALENV_VERIFY} ${LEXICALENV_OUTPUT}
)
add_custom_target(lexicalenv
    DEPENDS ${LEXICALENV_OUTPUT} ${LEXICALENV_VERIFY}
)
add_dependencies(lexicalenv es2panda ark)
add_dependencies(ecmascript_common_tests lexicalenv)
